<!DOCTYPE html>
<html>
<head>
    <title>仓库</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.storeCode" @on-enter="query" placeholder="仓库代码"></i-input>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="仓库名称"></i-input>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>

<script>
    // 获取
    var type = getQueryString("type");
    var url='../storehouse/list';
    if (type){
       url += '?moduleType='+type
    }
    $(function () {
        $("#jqGrid").Grid({
            url:url ,
            colModel: [
                {label: '仓库代码', name: 'storeCode', index: 'STORE_CODE', width: 80},
                {label: '仓库名称', name: 'name', index: 'NAME', width: 80},
                {label: '仓库类型', name: 'storeType', index: 'STORE_TYPE', width: 80,formatter: function(value){
                        return sysEnums.STORE_TYPE[value];
                    }},
                {label: '模块类型', name: 'moduleType', index: 'MODULE_TYPE', width: 80,formatter: function(value){
                        return sysEnums.STORE_TYPE_2[value];
                    }},
                // {label: '删除标识', name: 'delFlag', index: 'DEL_FLAG', width: 80},
                // {label: '备注信息', name: 'remark', index: 'REMARK', width: 100},
                // {label: '所属工厂ID', name: 'deptId', index: 'DEPT_ID', width: 80},
                // {label: '工厂名称', name: 'deptName', index: 'DEPT_NAME', width: 80},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true}
            ]
        });
    });

    let vm = new Vue({
        el: '#rrapp',
        data: {
            storeHouse: {},
            ruleValidate: {},
            q: {
                storeCode: '', // 仓库编码
                name:'' // 仓库名称
            },
            columnId: ''
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function () {
                vm.q = {
                    storeCode: '',
                    name:''
                };
                vm.reload();
            }
        }
    });
    var getStoreHouse = function () {
        let result = getSelectedRowData("#jqGrid");
        var id = result.id;
        if (id == null) {
            return false;
        } else {
            return result;
        }
    }
</script>
</body>
</html>
